<template>
  <div class="bar">
    <var-cell>
      <!-- 菜单按钮 -->
      <template #icon>
        <var-icon
          @click="doBtn"
          :name="page == 1 ? 'menu' : 'chevron-left'"
          :size="24"
          color="#000"
        />
      </template>
      <template #extra v-if="page === '1'">
        <var-icon name="magnify" color="#000" @click="searchData" :size="24" />
      </template>
      {{ title }}
    </var-cell>
    <var-popup overlay-class="popup" position="left" v-model:show="openAbout">
      <OpenAbout></OpenAbout>
    </var-popup>
  </div>
</template>

<script setup>
import { ref } from 'vue'
import { useRouter } from 'vue-router'
import OpenAbout from './openAbout.vue'

const props = defineProps({
  title: String,
  page: String
})

const router = useRouter()

const openAbout = ref(false)

const doBtn = () => {
  // 看在哪个页面，做什么事件
  if (props.page == 1) {
    openAbout.value = true
  } else {
    router.go(-1)
  }
}

const searchData = () => {
  router.push('/search')
}
</script>

<style lang="less" scoped>
.var-cell {
  font-family: Source Han Sans CN;
  font-size: 18px;
  font-weight: lighter;
  text-align: center;
  color: #000000;
}
</style>
